package com.znyj.cloud.device.constant;

/**
 * Created by hexin on 15-1-13.
 */
public class SysConstant {
    public final static boolean DEBUG_DISPLAY = true;
    public final static int PAYLOAD_MAX_BYTE = 4096;
    public final static int TIMEOUT_CONNECT = 10;
    public final static int TIMEOUT_HEARTBEAT = 150;
    public final static int PORT = 9977;
    public final static long DEFAULT_TIME = 1000;

    public final static int TASK_RECEIVE_OK = 1;
    public final static int TASK_RECEIVE_ERR = 2;
    public final static long TIME_2000 = 946656000;
    public final static long JUST_LOSS_CLOSE = 11111111;

    public final static int AUTOCLOSE_CNT = 3;
    public final static int PACKETLOSS_CNT = 3;

    public static class CDB_OP {
        public final static int INSERT_FIRST = 0;
        public final static int UPDATE_REPORT = 1;
        public final static int UPDATE_OFFLINE = 2;
        public final static int INSERT_TASK = 3;
        public final static int UPDATE_SEND_STATUS = 4;
        public final static int UPDATE_OTA_TIME = 5;
        public final static int GET_A_ORDER = 6;
        public final static int GET_B_ORDER = 7;
        public final static int UPDATE_POIID = 8;
    }

    public static class HEAD {
        public final static int HEAD_CRC_ADDR = 4;
        public final static int HEAD_VERSION_ADDR = 8;
        public final static int HEAD_FORMAT_ADDR = 12;
        public final static int HEAD_RESERVED_ADDR = 16;
        public final static int HEAD_LENGTH_ADDR = 20;
        public final static int HEAD_LENGTH = 24;

        public final static int PROTOCOL_HEAD = -889275714;
        public final static int FORMAT_BYTE = 0x00000001;
        public final static int FORMAT_JSON = 0x00000002;
        public final static int VERSION_1 = 0x00000001;
        public final static int RESERVE = 0x00000000;
    }

    public static class PACKAGE_VALUE {
        public static final String HAERTBEAT_RECEIVE = "hb_pac";
        public static final String HEARTBEAT_RES_SENT = "hb_res";
        public static final String CTRL_SENT = "ctrl_pac";
        public static final String CTRL_RES_RECEIVE = "ctrl_res";
        public static final String DETAIL_SENT = "det_pac";
        public static final String DETAIL_RES_RECEIVE = "det_res";
        public static final String UP_SENT = "up_pac";
        public static final String UP_RES_RECEIVE = "up_res";
        public static final String UP_OK = "ok";
        public static final String UP_FAIL = "fail";
    }

    public static class RETURN_MSG_VALUE {
        public static final String GET_CTRL = "ok";
        public static final String GET_ERROR = "fail";
    }

    public static class REPORT_KEY {
        public static final String SIG_QUALITY = "CSQ";
        public static final String LOCATION = "LOC";
        public static final String BATTERY_CYCLETIME = "BCC";
        public static final String ERROR_STATUS = "ERR";
        public static final String IS_GPSFIX = "IGF";
        public static final String IMEI = "IMEI";
        public static final String BATTREY_LEVEL = "BL";
        public static final String BATTERY_TEMPERATURE = "BT";
        public static final String BATTERY_STATUS = "BS";
        public static final String F_VERSION = "MVER";
        public static final String BATTERY_VOLTAGE = "BV";
        public static final String MSG_TYPE = "PTY";

        public static final String BATTERY_STATUS_B = "BSB";
        public static final String BATTERY_STATUS_A = "BSA";
        public static final String DEVICE_ID = "ID";
        public static final String CHARGE_IN = "CS";
        public static final String M_VERSION = "FVER";

        public static final String MAC = "MAC";

        public static final String RECEIVE_TIME = "RTM";
        public static final String HS_MSG = "HS";
    }

    public static class CTRL_KEY {
        public static final String MSG_TYPE = "PTY";
        public static final String DEVICE_ID = "ID";
        public static final String IMEI = "IMEI";
        public static final String ORDER_ID = "OID";
        public static final String ORDER_CREATE_TIME = "OTM";
        public static final String CONTROL_MSG = "CMSG";
        public static final String CS_MSG = "CS";
    }

    public static class UP_KEY {
        public static final String MSG_TYPE = "PTY";
        public static final String DEVICE_ID = "ID";
        public static final String IMEI = "IMEI";
        public static final String UP_STATUS = "US";
    }

    public static class ERROR_CODE {
        public static final int ONLINE_COUNT = 0;
        public static final int SQL_POOL_WARN = 1;

        public static final int FIRST_ERROR = 10;
        public static final int HEAD_ERROR = 11;
        public static final int VERSION_ERROR = 12;
        public static final int FORMAT_ERROR = 13;
        public static final int CRC_ERROR = 14;
        public static final int JSON_PARSE_ERROR = 15;


        public static final int LESS_24_BYTE = 16;
        public static final int EQ_0_BYTE = 17;
        public static final int LESS_ONE_PAG = 18;
        public static final int MORE_ONE_PAG = 19;
        public static final int OVER_MAX_SIZE = 20;
        public static final int UNKNOWN = 21;
        public static final int BIND_MULI_POIID = 22;
        public static final int BIND_NULL_POIID = 23;

        public static final int RECONNECT = 31;
        public static final int OFFLINE_DEV = 32;
        public static final int OFFLINE_NO_DEV = 33;
        public static final int READ_IDLE = 34;
        public static final int OFFLINE_MULT_DEV = 35;
        public static final int KICKOFF_OVERTIME_DEV = 36;
        public static final int WRITE_AND_FLUSH = 37;

        public static final int THRIFT_MSG_NOT_VALID = 50;
        public static final int THRIFT_DEV_NOT_ONLINE = 51;
        public static final int THRIFT_OPEN_ALREADY = 52;
        public static final int THRIFT_CLOSE_ALREADY = 53;

        public static final int TEST = 100;
    }

    public static class API_ERROR_CODE {
        public static final int THRIFT_SEND_UP_OK = 1;
        public static final int THRIFT_SEND_TASK_OK = 1;
        public static final int THRIFT_MSG_INVALID = 2;
        public static final int THRIFT_DEV_OFFLINE = 3;
        public static final int THRIFT_OPEN_ALREADY = 11;
        public static final int THRIFT_CLOSE_ALREADY = 12;
    }

    public enum UNIQUENESS {
        ONLY_ONE(1), MULTIPLE(-1), ON_ONE(0);
        private final int code;

        private UNIQUENESS(int code) {
            this.code = code;
        }

        public int code() {
            return this.code;
        }
    }
}
/*
{
        "CSQ": 21,
        "LOC": "E,,N,",
        "BCC": "",
        "ERR": "",
        "IGF": false,
        "IMEI": "868575020843266",
        "BL": 1,
        "BSB": 0,
        "CS": "off",
        "BS": "close",
        "BSA": 0,
        "BT": "",
        "MVER": "Luat_V0005_Air202",
        "BV": "",
        "PTY": "hb_pac",
        "ID": "112173300002",
        "FVER": "1.5.0"
}
{
    "CSQ": 23,
    "LOC": "E,,N,",
    "BCC": "",
    "ERR": "",
    "IGF": false,
    "IMEI": "862991419823825",
    "BL": 100,
    "BS": "open",
    "BT": "",
    "MVER": "Luat_V0004_Air202_DEBUG",
    "BV": "",
    "PTY": "hb_pac",
    "SN": "0000000000"
}
*/